<?php PageUtil::addVar("stylesheet","<link href=\"".$stylepath."/widget.css\" rel=\"stylesheet\">");
  if(!empty($listpost)){
?>
<div class="container widget tent-widget">
  <div>
  <h2>เต้นท์รถทั่วไทย</h2>
    <?php
        foreach ($listpost as $key => $value) {
          if(!empty($value)){
    ?>
      <div class="tent-widget-list">
        <a href="<?php echo base_url('post/view/'.$value["url"]);?>" target="_blank">
          <span class="tent-widget-brand-link"><?php echo $value["brand"][0]["name"];?></span>
          <span class="tent-widget-province"><?php echo $value["province"];?></span>
          <div class="tent-widget-model"><span><?php echo $value["model"][0]["name"];?></span> <span><?php echo (!empty($value["postMeta"]["horsepower"]) ? $value["postMeta"]["horsepower"]." แรงม้า":"ไม่ระบุแรงม้า");?></span></div>
          <div class="tent-widget-image">
            <?php
              if(!empty($value["images"][0]["small"])){
                ?>
                <img src="<?php echo base_url($value["images"][0]["medium"])?>" alt="<?php echo $value["title"];?>"/>
                <?php
              }else{
                ?>
                <img src="<?php echo $imagepath."/not_available-2.jpg"?>" alt="<?php echo $value["title"];?>"/>
                <?php
              }
            ?>
          </div>
          <div class="tent-widget-price"><span>ราคา</span> <span><?php echo number_format(intval($value["postMeta"]["price"]), 0, '.', ',');?>.-</span></div>
        </a>
      </div>
    <?php 
          }else{
    ?>
      <div class="tent-widget-list">
        <a href="<?php echo base_url('post/view/'.$value["url"]);?>" target="_blank">
          <span class="tent-widget-brand-link">ตำแหน่งว่าง</span>
          <span class="tent-widget-province"></span>
          <div class="tent-widget-model"><span>ติดต่อ 086-000-0000</span> <span></span></div>
          <div class="tent-widget-image">
             <img src="<?php echo $imagepath."/not_available-3.png"?>" alt=""/>
          </div>
          <div class="tent-widget-price"></div>
        </a>
      </div>
    <?php
          }
        }
    ?>
  </div>
  <div class="tent-more-post">
    <hr />
    <a href="<?php echo base_url("tent");?>" class="btn pull-right btn-success btn-small"><img src="<?php echo $imagepath;?>/icon-list.png" alt="ดูประกาศรถเต้นท์ทั้งหมด"> ดูประกาศรถเต้นท์ทั้งหมด</a>
  </div>
  
</div>
<?php
  }
?>